package com.briup.jz.web.controller;

import java.util.List;

import javax.validation.constraints.NotNull;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.jz.bean.CertificationApply;
import com.briup.jz.bean.extend.CertificationApplyExtend;
import com.briup.jz.service.ICertificationApplyService;
import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@Api(description = "CertificationApply(实名认证申请表)相关接口")
@Validated
@RestController
@RequestMapping("/certificationApply")
public class CertificationApplyController {
	@Autowired
	private ICertificationApplyService certificationApplyService;

	@ApiOperation(value = "查询所有实名认证申请")
	@GetMapping("query")
	public Message query(String name) {
		List<CertificationApply> list = certificationApplyService.query(name);
		return MessageUtil.success(list);
	}

	@ApiOperation(value = "通过id删除实名认证申请")
	@GetMapping("deleteById")
	@ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "主键", paramType = "query", required = true), })
	public Message deleteById(@NotNull Long id) {
		certificationApplyService.deleteById(id);
		return MessageUtil.success("删除成功");
	}

	@ApiOperation(value = "保存或更新实名认证申请")
	@ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "主键", paramType = "form"),
			@ApiImplicitParam(name = "realname", value = "真实姓名", paramType = "form", required = true),
			@ApiImplicitParam(name = "idCard", value = "身份证号", paramType = "form"),
			@ApiImplicitParam(name = "idcardPhotoPositive", value = "身份证照正面照", paramType = "form"),
			@ApiImplicitParam(name = "idcardPhotoNegative", value = "身份证反面照", paramType = "form"),
			@ApiImplicitParam(name = "bankCard", value = "银行卡号", paramType = "form"),
			@ApiImplicitParam(name = "bankCardPhoto", value = "银行卡照片", paramType = "form"),
			@ApiImplicitParam(name = "status", value = "申请状态", paramType = "form"),
			@ApiImplicitParam(name = "applyTime", value = "申请时间", paramType = "form"),
			@ApiImplicitParam(name = "reason", value = "申请原因", paramType = "form"),
			@ApiImplicitParam(name = "userId", value = "用户id", paramType = "form"), })
	@PostMapping("saveOrUpdate")
	public Message saveOrUpdate(CertificationApply certificationApply) {
		certificationApplyService.saveOrUpdate(certificationApply);
		return MessageUtil.success("更新成功");
	}
	@ApiOperation(value = "级联查询实名认证及姓名")
	@ApiImplicitParams({ @ApiImplicitParam(name = "beginTime", value = "开始时间", paramType = "query"),
			@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query"),
			@ApiImplicitParam(name = "status", value = "状态[通过,不通过]", paramType = "query"),
			@ApiImplicitParam(name = "userId", value = "申请人ID", paramType = "query"),
			})
	@GetMapping("selectCertificationUser")
	public Message selectCertificationUser(String beginTime, String endTime, String status,
			Long userId) {
		List<CertificationApplyExtend> list = certificationApplyService.selectCertificationUser(beginTime, endTime,
				status, userId);
		return MessageUtil.success(list);

	}

}
